package com.lzs.Service.Impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lzs.DAO.FamilyDAO;
import com.lzs.PO.Family;
import com.lzs.PO.Page;
import com.lzs.Service.FamilyService;

@Service
public class FamilyServiceImpl implements FamilyService  {
  @Autowired
  FamilyDAO familyDAO;
	
	public Page<Family> findFamilyPagelist(String keyword, Integer pageSize, Integer pageNum) {
		
		List<Family> arealist = this.familyDAO.findFamilyList(keyword);

		int totalRecord = arealist.size();

		Page<Family> page = new Page<Family>(pageNum, pageSize, totalRecord);

		int startIndex = page.getStartIndex();

		page.setList(familyDAO.findFamilyPagelist(keyword, startIndex, pageSize));
		
		return page;
	}

	
	public Boolean countFamilyByAdress(String family_adress) {
		long count = this.familyDAO.countFamilyByAdress(family_adress);
		return count==0;
	}

	
	public void addFamily(Map<String, Object> map) {
		
		this.familyDAO.addFamily(map);
		
	}

	
	public Family findFamilyWithMember(String family_id) {
		
		Family family = this.familyDAO.findFamilyWithMember(family_id);
		
		return family;
	}

	
	public Family findFamilyByFamilyId(String family_id) {
		
		Family family = this.familyDAO.findFamilyByFamilyId(family_id);
		
		return family;
	}

	
	public void updateFamily(Map<String, Object> map) {
		
		this.familyDAO.updateFamily(map);
		
	}

	
	public void deleteFamily(String family_id) {
		
		this.familyDAO.deleteFamily(family_id);
		
	}


	
	public List<Family> findFamilyList(Object object) {
		List<Family> list =this.familyDAO.findFamilyList(null);
		return list;
	}

}
